<template>
	<view class="animated fadeIn faster">
		<view class="p-3">
			<view class="bg-fff rounded15 d-flex d-flex-between d-flex-middle p-3 mb-3" v-for="chapter in chapterList" :key="chapter.id" @click="goQuestion(chapter.id)">
				<view class="d-flex-item text-clamp font30">{{chapter.name}}</view>
				<text class="iconfont icon-arrow-right color5c font28"></text>
			</view>
		</view>
	</view>
</template>

<script>
	import { userApi } from "@/http/userApi"
	import store from '@/store/index.js'
	import {mapState} from "vuex"
	export default {
		data() {
			return {
				chapterList:[]
			}
		},
		computed:{
			...mapState({
				loginState: state => state.loginState,
				cid: state => state.cid
			})
		},
		onReady() {
			this.getDailyList()
		},
		methods: {
			getDailyList(){
				let that = this
				uni.showLoading({
					title:'加载中...',
					mask:true
				})
				userApi.getChapterList(that.cid).then((res)=>{
					uni.hideLoading()
					that.chapterList = res
				}).catch((e)=>{
					console.log('chapter-e',e)
				})
			},
			goQuestion(cid){
				// userApi.getDailyList(cid).then((res)=>{
				// 	console.log('daily',res)
				// }).catch((e)=>{
				// 	console.log('e',e)
				// })
				uni.navigateTo({
					url:'/subPages/chapter/chapter?chapter='+cid
				})
			}
		}
	}
</script>

<style>

</style>
